﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Diagnostics;

namespace CompositionPlugin.Service
{
    public class ComposeDataTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item == null)
                return null;
            var service = SystemRuntime.Current.GetService<IDataTemplateManager>();
            if (service != null)
            {
                return service.GetTemplate(item.GetType());
            }
            else
            {
                // log
                SystemRuntime.Current.Log.Write(TraceEventType.Warning, 0, "ComposeDataTemplateSelector: IDataTemplateManager runtime service not found");
                return null;
            }
        }
        /// <summary>
        /// For m2
        /// </summary>
        /// <param name="item"></param>
        /// <param name="container"></param>
        /// <param name="viewState"></param>
        public virtual DataTemplate SelectTemplate(object item, DependencyObject container, string viewState)
        {
            throw new NotImplementedException();
        }
    }
}
